/*
 *  Copyright (C) 2011  Clint Priest
 *
 *  This file is part of Snap Graph.
 *
 *  Snap Graph is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Snap Graph is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Snap Graph.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

var DataElementsLasso = Class.create(UserElementLasso, {
	SelectableElementSelectors:		[ 'TD' ],
	LassoElementStyle:				{ },
	
	initialize: function($super) {
		$super();
		
		this.UserSelection = new UserSelection();
	},
	
	OnMouseUp: function($super, e) {
		var Dragging = this.Dragging;
		
		if(this.Dragging) {
			var evt = document.createEvent('Event');
			evt.initEvent('DataElementLasso:SelectionMade', true, true);
			
			evt.UserSelection = this.UserSelection;
			this.UserSelection.Unhighlight();

			this.Document.body.dispatchEvent(evt);
			this.UserSelection = new UserSelection();	// Reset user selection object (losing reference to previous)
		}
		
		$super(e);
		
		if(Dragging) {
			StopNextContextMenuPopup();
		}
	},
	/* Highlights how the selected elements will be used */ 
	HighlightSelectedElements: function(SelectedElements) {
		this.UserSelection.SelectedElements = SelectedElements;
		this.UserSelection.Highlight();
	},

});